package com.softkey;

public class SoftKey3 {

	jsyunew3 j9;
	SoftKey3()
	{
		j9=new  jsyunew3();
	}

	private String myhex(byte indata)
	{
		String outString;
		outString=String.format("%X",indata);
		if(outString.length()<2)outString="0"+outString;
		return outString;
	}

	//��ĳ�ֽ�Ϊ�������轫��ת���޷�������
    private  long conver(byte temp){
        long tempInt = (int)temp;
        if(tempInt < 0){
            tempInt += 256;
        }
        return tempInt;
    }

	 //�������ڽ�16�����ַ���ת��Ϊ�޷��ų�����
    private int HexToInt(String s)
    {
        String [] hexch = { "0", "1", "2", "3", "4", "5", "6", "7",
						       "8", "9", "A", "B", "C", "D", "E", "F"};
        int i, j;
        int r, n, k;
        String ch;

        k = 1; r = 0;
        for (i = s.length(); i > 0; i--)
        {
            ch = s.substring(i - 1,  i-1+1);
            n = 0;
            for (j = 0; j < 16; j++)
            {
                if (ch.compareToIgnoreCase(hexch[j]) ==0 )
                {
                    n = j;
                }
            }
            r += (n * k);
            k *= 16;
        }
        return r;
    }


    public String  StrEnc(String InString , String Key)//ʹ����ǿ�㷨�������ַ���
    {

        byte [] b,outb;
        byte []temp_b=InString.getBytes();
        byte [] temp=new byte[8],outtemp=new byte[8];
        int n,i,nlen,outlen;
        String outString;

        nlen = temp_b.length;
        nlen=nlen+1;
        if( nlen < 8 )
            outlen = 8;
        else
            outlen = nlen;
        b=new byte[outlen];
        outb=new byte[outlen];

        for(n=0;n<nlen-1;n++)
        {
        	b[n]=temp_b[n];
        }

        outb=b.clone();

        for( n = 0; n<=outlen - 8 ;n=n+ 8)
        {
            for (i = 0; i < 8; i++) temp[i] = b[i + n];
            EnCode(temp, outtemp, Key);
            for( i = 0 ;i<8;i++) outb[i + n] = outtemp[i];
        }

        outString = "";
        for (n = 0 ;n<= outlen - 1;n++)
        {
            outString = outString +myhex(outb[n]) ;
        }
        return outString;
    }

    public String  StrDec(String InString , String Key)//ʹ����ǿ�㷨�������ַ���
    {

        byte [] b,outb;
        byte [] temp=new byte[8],outtemp=new byte[8];
        int n,i,nlen,outlen;
        String outString,temp_String;


        nlen = InString.length();
        if( nlen < 16 ) outlen = 16;
        outlen = nlen / 2;
        b=new byte[outlen];
        outb=new byte[outlen];

        i = 0;
        for (n = 1 ;n<= nlen ;n=n+2)
        {
            temp_String = InString.substring(n-1, n-1+2);
            b[i] = (byte)HexToInt(temp_String);
            i = i + 1;
        }

        outb=b.clone();

        for( n = 0; n<=outlen - 8 ;n=n+ 8)
        {
            for (i = 0; i < 8; i++) temp[i] = b[i + n];
            DeCode(temp, outtemp, Key);
            for( i = 0 ;i<8;i++) outb[i + n] = outtemp[i];
        }

        outString=new String(outb);
        outString=outString.trim();
        return outString;
    }

	public void EnCode(byte[] inb, byte[] outb,  String Key )
    {

		long cnDelta,y,z,a,b,c,d,temp_2;
		long [] buf=new long[16];
       int n,i,nlen;
       long sum;
       long temp,temp_1;
       long mask=4294967295L;

       //UInt32 temp, temp_1;
       String temp_String ;


       cnDelta = 2654435769L;
       sum = 0;

       nlen = Key.length();
       i = 0;
       for( n = 1 ;n<= nlen ;n=n+2)
       {
           temp_String =Key.substring(n-1, n-1+2);
           buf[i] =HexToInt(temp_String);
           i = i + 1;
       }
       a = 0 ; b = 0 ; c = 0 ; d = 0;
       for(n = 0;n<=3;n++)
       {
           a = (buf[n] << (n * 8)) | a;
           b = (buf[n + 4] << (n * 8)) | b;
           c = (buf[n + 4 + 4] << (n * 8)) | c;
           d = (buf[n + 4 + 4 + 4] << (n * 8)) | d;
       }


       y = 0;
       z = 0;
       for(n = 0;n<=3;n++)
       {
           temp_2 = conver(inb[n]);
           y = (temp_2 << (n * 8)) | y;
           temp_2 = conver(inb[n + 4]);
           z = (temp_2 << (n * 8)) | z;
       }


       n = 32;

       while (n > 0)
       {
           sum = (cnDelta + sum)& mask;

           temp = (z << 4) & mask;
           temp = (temp + a) & mask;
           temp_1 = (z + sum) & mask;
           temp = (temp ^ temp_1) & mask;
           temp_1 = (z >> 5) & mask;
           temp_1 = (temp_1 + b) & mask;
           temp = (temp ^ temp_1) & mask;
           temp = (temp + y) & mask;
           y = temp & mask;
           /*y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); */

           temp = (y << 4) & mask;
           temp = (temp + c) & mask;
           temp_1 = (y + sum) & mask;
           temp = (temp ^ temp_1) & mask;
           temp_1 = (y >> 5) & mask;
           temp_1 = (temp_1 + d) & mask;
           temp = (temp ^ temp_1) & mask;
           temp = (z + temp) & mask;
           z = temp & mask;
           /* z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); */
           n = n - 1;

       }
       for(n = 0;n<=3;n++)
       {
           outb[n] = (byte)((y >>> (n * 8)) & 255);
           outb[n + 4] =(byte)((z >>> (n * 8)) & 255);
       }
    }

	public void DeCode(byte[] inb, byte[] outb,  String Key )
    {

		long cnDelta,y,z,a,b,c,d,temp_2;
		long [] buf=new long[16];
       int n,i,nlen;
       long sum;
       long temp,temp_1;

       long mask=4294967295L;

       //UInt32 temp, temp_1;
       String temp_String ;


       cnDelta = 2654435769L;
       sum = 3337565984L;

       nlen = Key.length();
       i = 0;
       for( n = 1 ;n<= nlen ;n=n+2)
       {
           temp_String =Key.substring(n-1, n-1+2);
           buf[i] =HexToInt(temp_String);
           i = i + 1;
       }
       a = 0 ; b = 0 ; c = 0 ; d = 0;
       for(n = 0;n<=3;n++)
       {
           a = (buf[n] << (n * 8)) | a;
           b = (buf[n + 4] << (n * 8)) | b;
           c = (buf[n + 4 + 4] << (n * 8)) | c;
           d = (buf[n + 4 + 4 + 4] << (n * 8)) | d;
       }


       y = 0;
       z = 0;
       for(n = 0;n<=3;n++)
       {
           temp_2 = conver(inb[n]);
           y = (temp_2 << (n * 8)) | y;
           temp_2 = conver(inb[n + 4]);
           z = (temp_2 << (n * 8)) | z;
       }


       n = 32;

       while (n > 0)
       {


           temp = (y << 4) & mask;
           temp = (temp + c) & mask;
           temp_1 = (y + sum) & mask;
           temp = (temp ^ temp_1) & mask;
           temp_1 = (y >> 5) & mask;
           temp_1 = (temp_1 + d) & mask;
           temp = (temp ^ temp_1) & mask;
           temp = (z - temp) & mask;
           z = temp & mask;
           /* z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); */

           temp = (z << 4) & mask;
           temp = (temp + a) & mask;
           temp_1 = (z + sum) & mask;
           temp = (temp ^ temp_1) & mask;
           temp_1 = (z >> 5) & mask;
           temp_1 = (temp_1 + b) & mask;
           temp = (temp ^ temp_1) & mask;
           temp = (y - temp ) & mask;
           y = temp & mask;
           /*y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); */

           sum = (sum-cnDelta)& mask;
           n = n - 1;

       }
       for(n = 0;n<=3;n++)
       {
           outb[n] = (byte)((y >>> (n * 8)) & 255);
           outb[n + 4] =(byte)((z >>> (n * 8)) & 255);
       }
    }

	public  long get_LastError()
	{
		return j9.get_LastError();
	}

	public String FindPort(int start)
    {
        return j9.FindPort(start);
    }

   public int CheckKeyByFindort_2()
    {
        //ʹ����ͨ�㷨һ����ָ���ļ�����
        String DevicePath = ""; //���ڴ�����������ڵ�·��
		DevicePath = j9.FindPort_2(0, 1, 916551414);
		int ret = (int)j9.get_LastError();
		j9.CloseUsbHandle(DevicePath);
		return ret;
    }


    //ʹ�ô����ȵķ�����ָ���ĵ�ַ��ȡ�ַ���
    private String ReadStringEx(int addr, String DevicePath)
    {
        int nlen, ret;
        byte[] buf = new byte[1];
        //�ȴӵ�ַ0������ǰд����ַ����ĳ���
		ret = j9.YReadEx((short)addr, (short)1, "AEB2B6FF", "17445C5A", DevicePath);
        if (ret != 0) return "";
		nlen = j9.GetBuf(0);
        //�ٶ�ȡ��Ӧ���ȵ��ַ���
		return j9.NewReadString(addr + 1, nlen, "AEB2B6FF", "17445C5A", DevicePath);

    }
    //ʹ�ôӴ�������ȡ��Ӧ���ݵķ�ʽ����Ƿ����ָ���ļ�����
    public int CheckKeyByReadEprom()
    {
        int n, ret;
        String DevicePath = "";//���ڴ�����������ڵ�·��
        String outString = "";
        //@NoUseCode_data return 1;//���û��ʹ��������ܣ�ֱ�ӷ���1
        for (n = 0; n < 255; n++)
        {
            DevicePath= j9.FindPort(n );
            if (j9.get_LastError() != 0) return (int)j9.get_LastError();
			outString = ReadStringEx(0, DevicePath);
			j9.CloseUsbHandle(DevicePath);
			if ((j9.get_LastError() == 0) && (outString.compareTo("ABC") == 0))
			{
				return 0;
			}
        }
        return -92;
    }
    //ʹ����ǿ�㷨һ�����������������������Ч�ط�ֹ����
    public int CheckKeyByEncstring()
    {
        //�Ƽ����ܷ�����������������������������㣬ͬʱ�ڳ����ж�ʹ�ô�����ͬ���ļ������㣬Ȼ����бȽ��жϡ�

        int n, ret;
        String DevicePath = "";//���ڴ�����������ڵ�·��
        String InString;

        //@NoUseKeyEx return 1;//���û��ʹ��������ܣ�ֱ�ӷ���1
        int number1=(int)(Math.random()*65535)+1;
        int number2=(int)(Math.random()*65535)+1;

        InString = (new   Integer(number1)).toString() + (new   Integer(number2)).toString();

        for (n = 0; n < 255; n++)
        {
           DevicePath= j9.FindPort(n );
            if (j9.get_LastError() != 0) return (int)j9.get_LastError();
			if (Sub_CheckKeyByEncString(InString, DevicePath) == 0)
			{
				return 0;
			}
        }
        return -92;
    }

    private int Sub_CheckKeyByEncString(String InString, String DevicePath)
    {
        //ʹ����ǿ�㷨һ���ַ������м���
        int ret;
        String outString = "";
        String outString_2;
		outString = j9.EncString(InString,DevicePath);
		if (j9.get_LastError() != 0) return (int)j9.get_LastError();
		outString_2 = StrEnc(InString, "C355E06E864E85A8102C1AEFAB72E2C7");
        if (outString_2.compareTo(outString) == 0)//�ȽϽ���Ƿ����
        {
            ret = 0;
        }
        else
        {
            ret = -92;
        }
        j9.CloseUsbHandle(DevicePath);
        return ret;
    }

	//ʹ����ǿ�㷨������Ƿ���ڶ�Ӧ�ļ�����
	public int CheckKeyByEncstring_New()
	{
		int n, ret;
		String DevicePath = "";//���ڴ�����������ڵ�·��
		String outString = "";
		int myrnd = (int)(Math.random() * 500);
		String[] EncInString ={ "6834","653","20745","2924","17089","24902","20517","23614","1489","6015","20290","6542","15851","16153","2236","31819","2105","10392","4873","10506","16133","27931","10950","20987","5049","8295","7340","30961","18655","8924",
"20373","20830","3106","4988","28283","16979","28746","25066","12921","2179","1860","104","19655","30783","7190","13784","28865","24442","3309","4027","32223","1990","17682","29747","18878","22612","22255","21507","2581","6135",
"13839","31885","24255","20256","4378","2515","31670","18914","19420","30838","29460","14831","6462","22457","7956","30872","13641","7038","11279","26832","16169","3654","17023","31017","13095","25395","20733","17877","1198","26632",
"30277","23204","22598","22311","2865","5387","23962","18834","19641","9754","18805","18666","9721","13444","28607","371","6697","7835","32132","5132","20133","23631","21229","2105","13542","309","32068","24091","21637","24189",
"20724","16502","13631","17658","9093","22185","26858","26397","9635","14009","13700","23289","23830","30534","24356","15424","16074","24979","4614","28227","26824","17282","27778","32245","31801","24979","10516","9193","5994","2284",
"26709","26189","28610","16715","6912","23287","3021","7956","3053","2393","7475","13640","2583","27777","31423","10123","12952","5413","14940","23580","23210","27541","27411","19936","6569","4549","28430","32342","29451","25924",
"30103","1956","8301","8519","5401","20104","31624","8349","1308","21606","2103","16315","30795","10559","7794","24241","5745","32182","13396","818","5751","21773","18455","6799","30822","22310","27158","23483","24426","17026",
"26314","18760","3021","32323","4301","21351","29942","19501","10969","6635","884","6816","29128","20037","27371","30366","18068","13704","9258","7627","30807","19046","1817","12390","11852","32560","1218","852","29132","8154",
"335","4629","22609","21491","19978","4300","19829","16559","17245","7738","31985","19168","31442","5570","23714","30967","10516","358","22143","29960","6124","11207","4772","11971","16451","21031","24905","7546","1062","30313",
"17610","8736","2236","20752","7072","2375","12367","25403","27236","11552","13388","10415","17874","14206","24378","27084","23747","979","26308","11669","8754","8496","26037","19371","5944","29767","30197","7761","13582","31083",
"27280","21608","30479","9871","10672","25459","1207","27970","9885","6548","31644","23736","31681","20364","22907","25539","9385","15038","1582","13013","22524","24363","32172","15871","391","8567","6675","24308","23600","30945",
"32154","5894","11268","16718","7326","28965","6188","11582","26517","998","9458","22484","5404","4985","19904","30417","3053","21425","16160","11416","27871","18943","12477","31274","15600","20342","24415","20779","12087","13000",
"9970","17883","3824","31302","15487","24860","18803","17892","2097","4721","6204","20785","8015","16892","19172","5474","24134","639","12581","2887","8864","25434","9433","3410","9477","25233","13306","22934","29504","32454",
"27298","13253","2621","26939","15628","10033","4099","22482","4497","26826","11709","30476","27306","22821","2485","31755","12532","9842","24916","22163","7462","3716","17191","773","16923","16589","26837","31840","14029","24669",
"12586","20043","24662","9706","14863","18181","23537","8642","6798","18800","2295","7641","15569","16143","13026","8129","22562","10756","23371","2731","2795","22288","9199","24937","5303","12182","22693","10351","12334","11160",
"6504","26573","3356","25527","9299","19766","27241","17206","16286","28155","20513","23030","17317","10512","26989","20090","17632","10500","32407","28644","24043","1548","3850","26613","6528","2040","2894","3345","31862","2106",
"12046","21559","12235","29668","31508","25355","19094","28074","20299","16847","15379","4061","9405","11620","21914","20078","26513","2382","29863","30959" };
		String[] EncOutString ={ "5BAFD5A18CB2B7D3","CE4F29BD0A25B785","0D18863463399271","91CC68124DFE888A","4ABA2AF30DD3B4DB","22F3EC712E720AB8","13E58993A4672482","0BC1F581DDE35FD7","209F360460D39BC9","9C3690B0FF281AE2","EAF96E0ED45381CE","E4F2E5C5AEFC9703","9188BD9CDEF41794","6F44D9FB402FEA89","29BCBA6565F5C79F","C0F40F493A43F843","B3AED57AE138C719","F5F1CA04284248E0","589617C1E12BFB81","C049E8F6B1BAA55F","5CFC0F7F4EECC685","317903F00C9AD746","3E7C91AB4D32678F","895545211B253BEE","F63ABE285F23CDA5","C8F60BC574AF4AB5","392EFD7A3AF70166","BFF3B9F7CFE49CEC","17C8AAC954711878","9FF057EC047FC471",
"911D2BDFC6A13687","72859AD2AB050182","114CC74D1DCF73E3","4B39691D83188297","1F095BF7D9529A27","8841BB718628F246","7CF4E7A5D1849893","0355BC9201A68766","EB3B87A2E5CF5A59","F9D36C8AC837F449","67C4C4F2AC0D090D","588AF8CAC0CBAAB1","F2EC9BFDD7A501F4","1666D869DE211F26","02A9A40873486706","F3711290971BDF5F","BA144CC76469E976","25BCCC88F6722048","382AEA90C890557C","B6C41D399FF6BD3C","331AA1DE9250DC15","19E65C7742C1D5D3","CDBA3CBEE0AE2B39","98D3BBEDED70F9DA","4F0778AC67C38EB1","84D203EF9A2A02B8","98A76EC5AAC39562","6B6E04FC6E4F17E2","CA590EDF31E728A5","C2AB07A398934DB6",
"E8069893D483C429","69945CF24562860A","8E516B037560E7B0","C9DA251F2A623925","2EC6E7C802FCB5A0","DFCC94B1B11C0AC3","486713EB4C607512","AADBFE63F9CC6BF5","DAC94FB118FCCEEF","81863D861DFACE58","34828AC7B7F2483D","257EBEE929318329","F74A3D4C9F113FC1","67A4B44241A37B57","9BF65EADBE30A090","7336852BC871823D","BB5352C1148DA825","8C720FB92910230D","0F861C268270B0BD","B16F427FD2879D34","EBEACE8CFC36DC89","99CFB47AC4A795A5","B91FE92FEE62CF95","B438D633C413403B","436CEBC017D46283","1077BBD2A0DEDC51","82B15DB378055617","6EF53FB5EBB2096D","293C38B998490230","B172A01EBF9B795A",
"089864871F7BE120","424B5BFB3718A2CE","6EB5DAB83C8B1E46","ACE6CBB8CDAFA87E","2CD143092BBC73AD","8F0D2AC6D9F87E9E","03BF232ACD5108BA","521D1152D57AB18F","DC036DAAB270BC1F","6A9A2440D9346CB9","803C19427FF2D050","B44888321C73A8D7","466D30047440C9DD","D87821E351674861","0BD416EEFCDF4642","514B410593E05C2E","285DAEE808041083","93EA4EF45B106A34","C0325A0B765A2429","3AF9F4E3BF1EC390","E2B3303663504234","5977893EED067F26","408744DAF84E4E02","B3AED57AE138C719","4C743F931DA0CF63","87652AACF593587F","D0BCE7F2D9B43216","B3FCD1C13C3A8926","6E58D03615834F2F","78EB25D3CA518562",
"328C3B763EC632A4","AA39158AFE983ADF","4FD5F0498BBECF33","B61A92421D8CF0CB","482E9E3E239E3A44","8D918427FC54DBB2","B369ECA1601FE58D","5E2E96AABFB617E1","C9F373F24365B3D8","CDC33B353C6859DA","054265660D44034C","86B1948F5B2A0F0A","9926CC097837C5A3","246281A151014828","83C355BA11F1D9AF","99706D2E5BD64117","4887114D479E9A93","8F5AF81204E5E5D0","5951D3BD1BBBDE52","26C9272F2F94B9BA","80EA51FC0459BA10","C83AFE5DE9A27CC3","ED58BC3E43FA0289","36A73B5AC4FF7D80","7BA848D5DB11BEE2","8F5AF81204E5E5D0","F01ACEEE7DAE3CCD","33DB8169C8F26DCB","6792387C01B979B2","E2208F89E606D33E",
"BAE52F653AAC5A29","D4106389E9A94CA1","070673697F10118E","166ED032A7E4624C","862C350D605443D2","9A0DE6FC9A76839A","19D992F995E6FEA5","9BF65EADBE30A090","260B5771CF5D6090","7F31580CBA86EFA5","BF6F81CFDCE431D8","847DC4210065400E","2DBC636458CA9820","F70AA16901988B79","4D2EFC32EC6808AB","48763B33F6FC7B4C","5A26EFF49B572D87","4B2988D26DDC8FBF","CE02E7EAB25892EF","C83AFADA1E79481F","7CDDA5EDB64C7267","E725587544EE4D95","A3C447A882129BF3","78DC03A54CAEE6BC","5AC8AD1AFA75A378","4E5B7085D58DF9B4","7C2ECB8DBFD4D887","490AAB5B4610FED6","FBD6B0515C089215","A35CD85C3E7A093A",
"37557C2A5D6B5B28","62527DB1B48937DC","C5241B03D23ACFE8","D0891CCEAB5A1976","68B9B267DBDDAFB6","8172DA1429CD4793","431451552C28F7F2","D479DC42B01E893A","66B9D6D20FB78BA8","24B8931BF3EDC749","E3519D014DBA3F7F","6A613E78342D72E0","E7647DEF12F52B40","431B1A685DD3103E","9F127AC875879AF8","35BB94AACD3C3CA2","2679E01E28C18B7D","3ABC7E8AD7E75DD8","281B57A9ACC2C1B4","C52816249732C519","7B59C1C9E6CA860D","2F48803A7842C84C","3B2405061FAE4EFD","5F0B165DF98B3B96","7011B31A39D13C07","20D3768E92B1EF93","B7EE4664A888C786","C1B9CC01311545E4","1A77DC0576ED2964","913E6444889E2A04",
"3D13DF4D6F4020B0","220E3094E3A5A952","19D992F995E6FEA5","42267CE1C44B1DF6","A33B0D12DF461C77","FE3BB774736D3B3E","136AB80E7488C042","C32EB38A80BA7BEA","45F25F753A6B85A1","DA91E95B71A09DCD","296CFA828AC00EB9","523CEFEC69A07EA5","B41266E42153A3C9","D4C8647C68F5CFCF","EE55D6B90F524199","B139B707954806A3","70DA84D30EA213C9","15C3776DD507FEFB","C12324ACC4E2C807","623A490ABA68F8E1","6DC6AA9CAE36EBB1","6BEA74414BD21096","CFE620A678F6AD82","41930ED6927C2A81","8296BF7A46C8A9B0","C1C499EF4CD629EF","C1834293A4B4D9D6","8BF1DF36C1916E79","93D0B64B2A291F75","99EE80A4F081D443",
"79DE9094809C605D","4C62DEEB3184FC29","EE80F21FDA4366CB","15C75F9810596353","447DC5B80491F206","C6757F5DA35EB552","E111DD4D25116B8E","C1ABCC88CE37BA5E","7B03CD20F982AD52","2352F16823D31497","E7CC5C1D07FCE587","7AF49EA9886EAE43","7368F98D3A0AAF1F","514ED88B56D00F44","3FD7B352919E885F","FD517D06ED511F75","F01ACEEE7DAE3CCD","12EE73C97FB9E55D","2C7B2844606C83A9","563A20B03BA194EB","1C900B00FCFB295C","8760CA31FE55CDDD","363F1CDA1514B7CA","0C682F265FE21093","5E0AB57C29A4B90E","2C3403F7B059FB88","9A9EA51046AD2D00","6D5D558FBE1FF101","7879FBFF18568947","BDE03B9B34470326",
"3427636C1630C024","BEC8DC42698EEFE7","29BCBA6565F5C79F","CFDDDA8BAA5C1AE8","71A428AD47AD8CB2","99D369F602D77D8D","630F3A811C048140","533A3588BC664958","FFF96B9757BBA82C","AA5E8A8040773F1F","E8189B020816608C","96B044F75095333A","F2360A139D0122D1","0871F465BF37F28E","786C490780B0ABBE","59BBE5B7A0CA005D","181C074D3FE24341","7A5E6965E89EBCA5","ACB08D800A048517","F043A18CAC7BBE82","8AFDE0F8906DD836","BB241366FEB0FF30","5058D87F7DC13634","F23C0BA4FA8EB62B","E72DC731F19A4A04","21E6DEE23D9CA178","4311EDEDC9D8275E","C0BFBB20D75261DA","5E913CD3DFA48DE1","E7945E02B9970756",
"9B5FCBB3C66D98E6","EECEE5D8C7D46EC4","9DD7D9DF42A22770","E795F8DAACE6CBA3","F4D7874207AE4ADA","8704E65452DE9747","3AF13406BD9E546D","E02F2A442CE9B9EC","6BA984F5D5D1D5A2","C83C7EF2879006CF","C3E6456C21705C81","42A7F7C51339858C","7C4BBE7F21926C9C","42D4E0703EA77DA6","BFEB28D66D23AD91","1D1C8B8C103B3DAF","071FB2B3FA201D71","A80AF6F157E8EB1A","E7A311AEBEF2725F","2681BE21B0B79780","874BD66EE638EC12","FEFCFA1242428AEA","02AECC497AE693C5","B979782C16B05DD5","EB5CCCAAC9E6E62B","40672CF782EA329E","EBB609B825B2539B","A8F2F6B1F416EA74","47D53301315160D5","DEC77099ED2195A9",
"ADD7B71ADAD4C440","F86A29BFDCA1CA62","7B650E13CF88EB85","CC2045297B261737","7FF5643E4A189568","0D1530B80A8731F4","B1664594E1D41933","84659FEF91CA7BFC","4E5A82C32CA70BDF","4A89BA21C65E24DA","4539792E290BCD34","96798B3B5BF94C35","4A55199D6425B8E4","22EEA93A550D0851","7B361488A3D1FBE4","125054EC69AE9990","260B5771CF5D6090","E1C0E48E039DD4DB","7D2163B82943A309","5B7064570659236B","D974C1911F839D7B","C545C51202B2FB40","875F5181CF81211B","0A89342D41DA6ECC","DAFBAB5C8D99BC61","8228219AED83B9AE","572DFC6DAEB1374D","71DADD42F43208E6","AFC9E6F530783459","49426F3772E074BD",
"B5104E1A9AD99AFA","963D05BC32139724","04878F364EB134D4","12F3F48DD9971C6C","0B9E79910E83E100","8DF0F7FB8D1049EA","319FB009DA8EFA8F","B625E94466C2276A","C56F60ABEB8FE8A4","6F3DE1888F5EAC2F","67924ADE1F406772","563CB7EEA32B4AC2","B10CB985FAA0A861","6BB9B5800D82ECDE","14353A94751DCC54","C8DC74681CFF92C7","AA1B45CE3DACF384","EE9465F7EF9017F9","DF7EBD4DED7166B8","39A656BB9AC7AF42","95AF23984981AFBA","4DFD9052ABF4220B","229619D150C21492","DE3A51E737729B04","1AFA67294AD1C87E","449358415BF1C875","4DFB247A43A53BD6","F62F9619830E3896","9CC21DD3DD46AF04","9DAAE560FEF0B463",
"68BB961B0AA5E084","AEDFBFC9B2E59F04","4182A53E37956503","A6D05370348D173F","55672E2466C7EC5F","3B5996F6D9FB9829","746BA4C4070A1469","114A4DF908DF7618","8B62E48D7D26D295","5AA9EE3DD5282005","BCB4438D4251A1C0","93FA05BCE1D03FF7","013FB8E6DFD1CF1C","DE0877844039505B","9A2136F653318834","36DF5ACC77FD592F","9738D9D75200106B","9E56A110531E215B","7D3AC37C62A166D8","0873EB1E74A252F3","FD17A96F9FC72E3B","3F31C8538CCF1126","3A8C934B7E4DFFFD","B4D7014D9A22C35E","0ABF00CF3955187A","03DB61F515E85BD8","4EF8367D96D70FAA","B03A3118FA17FFF7","01AE39838384D967","808D5462FD62D776",
"294587942B734E07","1BF47C43E7EECABD","6D5232FA098F4D4B","1A122F06C2AD759C","FB7022D90BAA11BB","F0BCA3444BD746CC","95FC4C6EA3A6E33D","771E32947BF31017","40BBC3618EFF4862","1B1394F9088B5F6C","11BAB9B4599FF59D","E09CCE3A39B071B3","F84007B34F1D6AA4","02007AB43881C457","6823331ED2802974","590A5A0222829939","8D717F12F25212AA","5E9AD6149E0BD7C6","C3D2867A670C8376","F66B15D80CE5C7C5","18B84764BDDF6140","50BF5F30F38F0245","FC241A3682F5B5A3","FAD880420697C7C4","658932D9DF532AC0","5136DFB10E9E534B","694E4D3E402873F0","2FF3E8D6525142DF","66B39A377A9A4B09","00334CD86C4A7D0F",
"A3A7AEA977E2C84F","92B438C2509C8239","DB0F29F3BD8F1096","33EB5E72620DBDCA","B495118AD8A76361","3F70775CE2D0B1E9","46C68AC89CC71B4A","9B503E4953437D02","0D908B64B2835B4B","CB5ED9C4648C1F51","C65747C0A0A9FC69","3B8A8B7C480645C3","8FF228DBA13A3AB0","38A10031D3614E68","D44A35F81B935573","1C6832F042DE1AA8","F9CF6000B84957D6","6F61C03F7D6A3922","1A0A0D47E382213F","369AEE38B21A9E2B","43E0C3DF61EBD492","1989DFCA46D2F719","55EBEEE730887665","28BFF5752D04A565","6C0C6D7778E0BC1E","46198330AFB907E6","94069FD6B4C1D976","374B5886DC787B59","5FAB5C4182C4BBB6","EA3FF4232F52BEED",
"5ACBC266D650DF10","4AB16382E535CCD3","5363CB140CF217CF","8B9B6ADBA2B60CA6","0645FF85A6676969","2F163591DAE9A76B","14CA8BDFDE00C978","A40C3AB99FE3FA35","DA94251DF6B7868C","87D84BB430CB883E","9035602C3D3A8A09","D4687B91CCC0A088","3FDCEA3492DACD5F","4109CE09F70C7E1A","678D4458AF4EFDE8","4B27AB8868625F3C","BBAC00C5B4473A47","477A257067ACEE3C","06E04CD89F799951","E40F80647880A9A2" };
		//@NoUseNewKeyEx return 1;//���û��ʹ��������ܣ�ֱ�ӷ���1
		//@NoSupNewKeyEx  return 2;//���������֧��������ܣ�ֱ�ӷ���2


		for (n = 0; n < 255; n++)
		{
			DevicePath = j9.FindPort(n);
			if (j9.get_LastError() != 0) return (int)j9.get_LastError();
			outString = j9.EncString_New(EncInString[myrnd], DevicePath);
			j9.CloseUsbHandle(DevicePath);
			if ((j9.get_LastError() == 0) && (outString.compareTo(EncOutString[myrnd]) == 0))
			{
				return 0;
			}
		}
		return -92;
	}


}
